<template>
  <div id="content">
    <div class="home-tab-bt">
      <div
        class="home_product"
        v-for="item in list"
        :key="item.id"
        @click="onProductDetail(item.id)"
      >
        <router-link :to="{ path: '/detail', query: { id: item.id } }">
          <img :src="item.picture" alt />
          <div class="home_pro_title">
            <span>生活优选</span>
            <span class="h1">{{ item.product }}</span>
          </div>
          <!-- 商品底部 -->
          <div class="home_pro_bt">
            <h4>￥{{ item.price }}元</h4>
            <!-- 新品vip -->
            <div class="home_pro_bt_vip">
              <span class="first">新品</span>
              <span class="second">VIP</span>
            </div>
            <span>...</span>
          </div>
        </router-link>
      </div>
    </div>
  </div>
</template>

<script>
import { getGoodsList } from "@/api/home";
export default {
  data() {
    return {
      list: [],
    };
  },
  async created() {
    let res = await getGoodsList();
    let { resultCode, resultInfo } = res.data;
    if (resultCode == 1) {
      this.list = resultInfo.list;
      console.log(this.list);
    }
  },
};
</script>

<style lang="less" scoped>
#content {
  background-color: #f4f4f4;
  .home-tab-bt {
    display: flex;
    flex-wrap: wrap;
  }
  //  商品列表信息
  .home_product {
    // float: left;
    width: 45%;
    background: #fff;
    padding-top: 0px;
    font-size: 12px;
    padding-left: 2%;
    padding-right: 1%;
    margin-bottom: 20px;
    margin-right: 2%;
    border-radius: 10px;
    img {
      margin: 0;
      width: 100%;
      height: 200px;
      margin-bottom: 20px;
    }
    p {
      margin-bottom: 5px;
    }
    .home_pro_title {
      margin-bottom: 20px;
      .h1 {
        font-size: 12px;
        background: 0;
        color: #000;
      }
      span {
        background: #ea8360;
        border-radius: 5px;
        margin-right: 5px;
        color: #fff;
      }
    }
    .home_pro_bt {
      display: flex;
      justify-content: space-between;
      margin-bottom: 10px;
      .home_pro_bt_vip {
        .first {
          background: #263f6b;
          color: #aaa098;
        }
        .second {
          background: #f9ddcb;
          color: #3e2819;
        }
      }
    }
  }
}
</style>